<?php

namespace app\admin\model;

use think\Model;


class Vip extends Model
{

    

    

    // 表名
    protected $name = 'vip';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'grade_type_text',
        'is_tiyan_text'
    ];
    

    
    public function getGradeTypeList()
    {
        return ['1' => __('Grade_type 1'), '2' => __('Grade_type 2'), '3' => __('Grade_type 3')];
    }

    public function getIsTiyanList()
    {
        return ['1' => __('Is_tiyan 1'), '2' => __('Is_tiyan 2')];
    }


    public function getGradeTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['grade_type']) ? $data['grade_type'] : '');
        $list = $this->getGradeTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsTiyanTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_tiyan']) ? $data['is_tiyan'] : '');
        $list = $this->getIsTiyanList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getImageAttr($value,$data)
    {
        if (empty($value)) return '';
        return cdnurl($value,true);
    }

//    public function getPramsjsonAttr($value,$data)
//    {
//        return is_array($data['pramsjson']) ? $data['pramsjson'] : json_decode($data['pramsjson'], true);
//    }
}
